#include "performanceWidget.h"
#include "configargs.h"

bool cpuburn_flag;

void Performance::CpuburnSolt()
{
	qDebug("cpu burn");
#if 0
	CpuBurn *tool = new CpuBurn;

	tool->setModal(true);
	tool->showFullScreen(); 
#endif
	cpuburn_flag ^= 1;
	this->setLabel("cpuburn");

	if(cpuburn_flag == 1)
	{
		system("wq_cpuburn &");
	}else if(cpuburn_flag == 0){
		system("killall -9 wq_cpuburn &");
	}
}

void Performance::SdspeedSolt()
{
#if 0
	qDebug("sdspeed");
	SdSpeedTest *tool = new SdSpeedTest;

	tool->setModal(true);
	tool->showFullScreen(); 
#else

	QMessageBox::information(NULL, tr("提示"), QString("请用文件浏览器测试"));


#endif
}

void Performance::PingSolt()
{
	qDebug("ping tool");

	PingTool *tool = new PingTool;

	tool->setModal(true);
	tool->showFullScreen(); 
}


Performance::Performance(QWidget *parent) : JDialog(parent)
{

	QGridLayout *pSubLayout 	= new QGridLayout;
	QVBoxLayout *cpuburnVBox 	= new QVBoxLayout;
	QVBoxLayout *sdspeedVBox 	= new QVBoxLayout;
	QVBoxLayout *pingVBox 		= new QVBoxLayout;

	QLabel *cpuburnLabel 	= new QLabel(this);
	QLabel *sdspeedLabel 	= new QLabel(this);
	QLabel *pingLabel 		= new QLabel(this);

	sdspeedBt = new QToolButton(this);
	pingBt	  = new QToolButton(this);
	cpuburnBt = new QToolButton(this);
	
	QFrame *pFrame = new QFrame(this);

	cpuburn_flag = 0;


	cpuburnLabel->setAlignment(Qt::AlignCenter);
	sdspeedLabel->setAlignment(Qt::AlignCenter);
	pingLabel->setAlignment(Qt::AlignCenter);
#if 0	
	cpuburnLabel->setStyleSheet("border: 1px solid  #ff0000");
	sdspeedLabel->setStyleSheet("border: 1px solid  #ff0000");
	pingLabel->setStyleSheet("border: 1px solid  #ff0000");
#endif	
	sdspeedBt->setStyleSheet("border-image: url(:/image/linuxdesktop/settingsicon/usbsd.png);");
	pingBt->setStyleSheet("border-image: url(:/image/linuxdesktop/settingsicon/ping.png);");
	cpuburnBt->setStyleSheet("border-image: url(:/image/linuxdesktop/settingsicon/cpuburn.png);");


	
	cpuburnLabel->setText("CPU满载");
	sdspeedLabel->setText("读写测试");
	pingLabel->setText("PING测试");

	if(g_lcdsize == LCDSIZE_480x272)
	{
		sdspeedBt->setFixedSize(75, 75);
		pingBt->setFixedSize(75, 75);
		cpuburnBt->setFixedSize(75, 75);
		cpuburnLabel->setFixedSize(75, 25);
		sdspeedLabel->setFixedSize(75, 25);
		pingLabel->setFixedSize(75, 25);

	}else {
		sdspeedBt->setFixedSize(150, 150);
		pingBt->setFixedSize(150, 150);
		cpuburnBt->setFixedSize(150, 150);
		cpuburnLabel->setFixedSize(150, 25);
		sdspeedLabel->setFixedSize(150, 25);
		pingLabel->setFixedSize(150, 25);
	}


	sdspeedVBox->addWidget(sdspeedBt);
	sdspeedVBox->addWidget(sdspeedLabel);
	pingVBox->addWidget(pingBt);
	pingVBox->addWidget(pingLabel);
	cpuburnVBox->addWidget(cpuburnBt);
	cpuburnVBox->addWidget(cpuburnLabel);


	pSubLayout->addLayout(sdspeedVBox, 		0,0,1,1);
	pSubLayout->addLayout(pingVBox, 		0,1,1,1);
	pSubLayout->addLayout(cpuburnVBox, 		0,2,1,1);


	connect(sdspeedBt, SIGNAL(clicked()), this, SLOT(SdspeedSolt()));
	connect(pingBt, SIGNAL(clicked()), this, SLOT(PingSolt()));
	connect(cpuburnBt, SIGNAL(clicked()), this, SLOT(CpuburnSolt()));

   
   
    pFrame->setLayout(pSubLayout);

    QGridLayout *pMainLayout = new QGridLayout;
    
    pMainLayout->addWidget(pFrame, 0, 0, 1, 1);
    pMainLayout->setContentsMargins(40, 15, 40, 15);
    
    pFrame->setObjectName("PerformanceFrame");
    
    this->setJLayout(pMainLayout);
    this->setJTitle(tr("性能测试"));

}



Performance::~Performance()
{

}















